<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
    <title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %>
</h1>
<br/>
<a href="hello-servlet">Hello Servlet</a>
<hr><h1>c:foreach 实现循环遍历</h1>
<%
    List<String> list = new ArrayList<>();
    list.add("aa");
    list.add("bb");
    list.add("cc");
    list.add("dd");
    list.add("ee"); pageContext.setAttribute("list", list);
%>
<c:forEach items="${list }" var="x">
    ${x } </c:forEach>
<c:forEach begin="0" end="100" step="2" var="i"> ${i }
</c:forEach>
<hr><h1>c:foreach案例:遍历10到100的偶数，如果数字所在的位置是3的倍数，显示成红色 </h1>
<c:forEach begin="10" end="100" step="2" var="i" varStatus="stat">
    <c:if test="${stat.count % 3 == 0 }"> <font color="red">${i }</font>
    </c:if>
    <c:if test="${stat.count % 3 != 0 }">
        <font color="blue">${i }</font> </c:if>
</c:forEach>
</body>
</html>